package easy;

/**
 * Created by daodao on 2017/11/30.
 * Problem 9
 * Description: Determine whether an integer is a palindrome. Do this without extra space.
 */
public class PalindromeNumber {
    public static boolean isPalindrome(int x) {
        if (x < 0 || x % 10 == 0 && x != 0) {
            return false;
        }
        int digit = 0;
        while (digit < x) {
            digit = digit * 10 + x % 10;
            x = x / 10;
        }
        return digit == x || digit / 10 == x;
    }
}
